package com.mojo.redisson.controller;

import com.mojo.redisson.observerPattern.ApplySubject;
import com.mojo.redisson.observerPattern.EmailObserverImpl;
import com.mojo.redisson.observerPattern.NoteObserverImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author <a href="mailto:mojo_jj@163.com">Mojo</a>
 */
@RestController
public class JobController {
    @Autowired
    private ApplySubject subject;
    @Resource
    private EmailObserverImpl emailObserver;
    @Resource
    private NoteObserverImpl noteObserver;

    /**
     * @param
     * @author Mojo
     */
    @GetMapping("observer")
    public void apply(String s) {
        System.out.println("报名...");
        subject.addObserver(emailObserver);
        subject.addObserver(noteObserver);
        subject.notifyObservers("报名完成");
    }
}
